package com.wwwarehouse.usercenter.fragment.permissiondistribute;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.widget.ListView;

import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.usercenter.R;
import com.wwwarehouse.usercenter.adapter.DistributePermissionErrorDetailsListAdapter;
import com.wwwarehouse.usercenter.bean.response.DistributePermissionArrayBean;

import java.util.ArrayList;

/**
 * 分配权限->权限分配失败详情
 * Created by ShineF on 2017/9/25 0025.
 */

public class DistributePermissionErrorDetailsFragment extends BaseFragment {

    private ListView mLvContent;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_distribute_error_details, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mLvContent = $(R.id.lv_content);
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof DistributePermissionErrorDetailsFragment) {
            mActivity.setTitle(R.string.distribute_permission_error);
        }
    }

    @Override
    public void requestDatas() {

    }

    @Override
    public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
        Bundle bundle = getArguments();
        if (null != bundle) {
            ArrayList<DistributePermissionArrayBean> arrayList = bundle.getParcelableArrayList("data");
            int page = bundle.getInt("page");
            int height = bundle.getInt("height");
            int size = bundle.getInt("size");
            ArrayList<DistributePermissionArrayBean> dataList = new ArrayList<>();
            if (null != arrayList) {
                for (int i = page * size; i < (page + 1) * size; i++) {
                    if (0 <= i && i < arrayList.size()) {
                        dataList.add(arrayList.get(i));
                    }
                }
            }
            DistributePermissionErrorDetailsListAdapter adapter = new DistributePermissionErrorDetailsListAdapter(mActivity, height, dataList);
            mLvContent.setAdapter(adapter);
        }
        return null;
    }
}
